package modifyx

import (
	"strings"
)

func NewRoot(source *Source) *Root {
	obj := &Root{}
	obj.Object = NewObject(obj)
	obj.source = source

	return obj
}

type Root struct {
	*Object

	source *Source
	// 默认的上下文
	ctx interface{}
	//
}

func (s *Root) RefSetContext(ctx interface{}) {
	s.ctx = ctx
}

func (s *Root) RefClassId() string {
	return s.source.id
}

func (s *Root) RefClassKey() string {
	return s.source.ClassKey()
}

func (s *Root) RefClassCatalog() string {
	return s.source.ClassCatalog()
}
func (s *Root) RefClassType() string {
	return s.source.ClassType()
}

func (s *Root) RefSource() *Source {
	return s.source
}

func (s *Root) RefDispose() {
	s.source.Dispose()
	s.source = nil
}

func ParseKey(key string) (kind, id string) {
	arr := strings.Split(key, "/")
	kind = arr[0]
	id = arr[1]
	return
}
